#!/bin/bash
proc() {
    echo -e "\033[42;32m > $@ \033[0m" >&2
    local command=("$@")
    if "${command[@]}"; then
        echo -e "\033[42;32m SUCCEED \033[0m \n" >&2
    else
        echo -e "\033[41;32m FAILED \033[0m \n" >&2
        exit 1
    fi
}

proc cp ../buildroot/buildroot-2017.08.1/output/images/rootfs.tar .
proc tar -xvf rootfs.tar -C ./fs2

autoeth=./fs2/etc/network/interfaces
proc echo 'auto eth0'>>${autoeth}
proc echo 'iface eth0 inet dhcp'>>${autoeth}

autossh=./fs2/etc/ssh/sshd_config
proc echo 'PasswordAuthentication yes'>>${autossh}
proc echo 'PermitEmptyPasswords yes'>>${autossh}
proc echo 'PermitRootLogin yes'>>${autossh}
